package cn.wolfcode.controller;

import cn.wolfcode.domain.Business;
import cn.wolfcode.domain.SystemDictionaryItem;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ISystemDictionaryItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private IBusinessService businessService;
    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;

    @RequestMapping("/index.html")
    public String show(Model model){
        //查总店
        List<Business> business = businessService.selectMainStore(1);
        model.addAttribute("mainstore",business.get(0));


        //获取业务分类
        List<SystemDictionaryItem> systemDictionaryItems =systemDictionaryItemService.selectByTypeId(1);
        model.addAttribute("systemDictionaryItems",systemDictionaryItems);

        //门店详情
        List<Business> businesses =businessService.selectAll();
        model.addAttribute("businesses",businesses);

        return "index";
    }
}
